import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//案例：HashMap集合存储学生对象并遍历
//需求：创建一个HashMap集合，键是学号（String)，值是学生对象（Student)。存储三个键值对元素，并遍历。
public class HashMapDemo01 {
    public static void main(String[] args) {
        HashMap<String,Student> hm = new HashMap<>();
        hm.put("1000",new Student("Jack",20));
        hm.put("1001",new Student("Judy",18));
        hm.put("1002",new Student("Lucy",23));
        hm.put("1003",new Student("Nanny",17));

        Set<Map.Entry<String, Student>> entrySet = hm.entrySet();
        for(Map.Entry<String, Student> me : entrySet)
            System.out.println(me.getKey() + " : " + me.getValue().getName() +"," + me.getValue().getAge());
    }
}
